package org.geebis.powerbrake;

public class Job {
    private String handbrakeOptions;

    private Kind kind = Kind.MOVIE;
    private String artworkFileName;
    private String network;
    private Integer season;
    private String episodeId;
    private Integer episodeNumber;
    private String sourceVideoTs;
    private String description;
    private String title;
    private String show;
    private Boolean explicit;
    private String genre;
    private String album;
    private String artist;
    private Integer year;
    private Integer track;
    private Integer trackCount;
    private Integer disc;
    private Integer discCount;

    private String filename;

    public String getHandbrakeOptions() {
        return handbrakeOptions;
    }

    public void setHandbrakeOptions(String handbrakeOptions) {
        this.handbrakeOptions = handbrakeOptions;
    }

    public Kind getKind() {
        return kind;
    }

    public void setKind(Kind kind) {
        this.kind = kind;
    }

    public String getArtworkFileName() {
        return artworkFileName;
    }

    public void setArtworkFileName(String artworkFileName) {
        this.artworkFileName = artworkFileName;
    }

    public String getNetwork() {
        return network;
    }

    public void setNetwork(String network) {
        this.network = network;
    }

    public Integer getSeason() {
        return season;
    }

    public void setSeason(Integer season) {
        this.season = season;
    }

    public String getEpisodeId() {
        return episodeId;
    }

    public void setEpisodeId(String episodeId) {
        this.episodeId = episodeId;
    }

    public Integer getEpisodeNumber() {
        return episodeNumber;
    }

    public void setEpisodeNumber(Integer episodeNumber) {
        this.episodeNumber = episodeNumber;
    }

    public String getSourceVideoTs() {
        return sourceVideoTs;
    }

    public void setSourceVideoTs(String sourceVideoTs) {
        this.sourceVideoTs = sourceVideoTs;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getShow() {
        return show;
    }

    public void setShow(String show) {
        this.show = show;
    }

    public Boolean getExplicit() {
        return explicit;
    }

    public void setExplicit(Boolean explicit) {
        this.explicit = explicit;
    }

    public String getGenre() {
        return genre;
    }

    public void setGenre(String genre) {
        this.genre = genre;
    }

    public String getAlbum() {
        return album;
    }

    public void setAlbum(String album) {
        this.album = album;
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public Integer getTrack() {
        return track;
    }

    public void setTrack(Integer track) {
        this.track = track;
    }

    public Integer getTrackCount() {
        return trackCount;
    }

    public void setTrackCount(Integer trackCount) {
        this.trackCount = trackCount;
    }

    public Integer getDisc() {
        return disc;
    }

    public void setDisc(Integer disc) {
        this.disc = disc;
    }

    public Integer getDiscCount() {
        return discCount;
    }

    public void setDiscCount(Integer discCount) {
        this.discCount = discCount;
    }

    public String getOutputFileName() {
        if (this.filename != null) {
            return this.filename;
        }

        // else, lets try to build a filename from the metadata
        if (this.getKind() == Kind.TV_SHOW) {
            if (this.getSeason() != null && this.getEpisodeNumber() != null) {
                return String.format("%s %dx%02d %s.mp4", this.getShow(), this.getSeason(), this.getEpisodeNumber(), this.getTitle());
            } else {
                return String.format("%s %s.mp4", this.getShow(), this.getTitle());
            }
        } else if (this.getKind() == Kind.MUSIC_VIDEO) {
            return String.format("%s %s.mp4", this.getArtist(), this.getTitle());
        } else {
            return String.format("%s.mp4", this.getTitle());
        }
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();

        buffer.append("Output Filename: ").append(this.getOutputFileName()).append("\n\n");

        buffer.append("Source: ").append(this.getSourceVideoTs()).append("\n");

        if (this.getShow() != null) {
            buffer.append("Show: ").append(this.getShow()).append("\n");
        }

        buffer.append("Title: ").append(this.getTitle()).append("\n");
        buffer.append("Handbrake Options: ").append(this.getHandbrakeOptions()).append("\n");

        if (this.getEpisodeNumber() != null) {
            buffer.append("Episode #: ").append(this.getEpisodeNumber()).append("\n");
        }

        if (this.getDescription() != null) {
            buffer.append("Description: ").append(this.getDescription()).append("\n");
        }

        if (this.getGenre() != null) {
            buffer.append("Genre: ").append(this.getGenre());
        }

        return buffer.toString();
    }
}
